package com.airport.schedule.model;

import java.util.Set;

public class AdHocRule {
    public static final int IS_DOWN_GREDE = 1;
    public static final int IS_COMPOSITE = 2;
    public static final int IS_RUNWAY_GATE = 3;


    private final Set<String> obstructRunInFlightGates; // 产生阻挡滑入机位
    private final Set<String> obstructFlightGates; // 完全阻挡滑入滑出
    private final Set<String> homogenyFlightGates; // 产生同质机位

    private final int ruleType; // 临时措施类型

    public AdHocRule(Set<String> obstructRunInFlightGates,
                     Set<String> obstructFlightGates,
                     Set<String> homogenyFlightGates,
                     int ruleType) {
        this.obstructRunInFlightGates = obstructRunInFlightGates;
        this.homogenyFlightGates = homogenyFlightGates;
        this.obstructFlightGates = obstructFlightGates;
        this.ruleType = ruleType;
    }

    public boolean affect(FlightGate gate) {
        String gateId = gate.getFlightGateId();
        return obstructFlightGates.contains(gateId)
                || obstructRunInFlightGates.contains(gateId)
                || homogenyFlightGates.contains(gateId);
    }

    public Set<String> getObstructRunInFlightGates() {
        return this.obstructRunInFlightGates;
    }

    public Set<String> getHomogenyFlightGates() {
        return homogenyFlightGates;
    }

    public Set<String> getObstructFlightGates() {
        return obstructFlightGates;
    }

    public int getRuleType() {
        return ruleType;
    }

    public String toString() {
        String desc = "";
        if(!obstructFlightGates.isEmpty()) {
            desc += "完全阻挡机位: "+obstructFlightGates;
        }
        if(!obstructRunInFlightGates.isEmpty()) {
            desc += "  阻挡滑入机位: "+ obstructRunInFlightGates;
        }
        if(!homogenyFlightGates.isEmpty()) {
            desc += "  同机位: "+homogenyFlightGates;
        }
        return desc;
    }
}
